﻿#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>




///    echo s > /dev/watchdog0


int main(void)
{
	// 打开watchdog
	int fd = open("/dev/watchdog0", O_WRONLY);
	if (fd == -1)
	{
		printf("error: open(/dev/watchdog)\n");
	}

	while (1)
	{
		// 喂狗
		int food = 0;
		ssize_t ret = write(fd, &food, sizeof(food));
		if (ret < 0)
		{
			printf("\n!!! error: write watchdog \n");
		}
		
		printf("clear watchdog ok \n");
		sleep(5);
	}
	
	close(fd);  // 无效

	return 0;
}
